﻿/* * 版 本 PIT-ADMS V7.0.3 敏捷开发框架
 * Copyright (c) 2013-2018 Hexagon PPM
 * 创建人：超级管理员
 * 日  期：2022-04-11 09:45
 * 描  述：项目备份表
 */
var acceptClick;
var keyValue = request('keyValue');
var bootstrap = function ($, learun) {
    "use strict";
    var page = {
        init: function () {
            $('.lr-form-wrap').lrscroll();
            page.bind();
            page.initData();
        },
        bind: function () {
            $('#FolderId').lrUploader({
                format: ".zip",
                multiple: false,
                callback: function (obj) {
                    if (obj.value != "" && obj.value != undefined && obj.value != null) {
                    }
                }
            });
        },
        initData: function () {
            if (!!keyValue) {
                $.lrSetForm(top.$.rootUrl + '/ZZDT_EC/ec_project_bakup/GetFormData?keyValue=' + keyValue, function (data) {
                    for (var id in data) {
                        if (!!data[id].length && data[id].length > 0) {
                            $('#' + id ).jfGridSet('refreshdata', data[id]);
                        }
                        else {
                            $('[data-table="' + id + '"]').lrSetFormData(data[id]);
                        }
                    }
                });
            }
            $("#lrUploader_uploadBtn_FolderId").remove();
            $(".lrUploader-input").css("width", "117%");
        }
    };
    // 保存数据
    acceptClick = function (callBack) {
        if (!$('#form').lrValidform()) {
            return false;
        }
        //文字特殊字符及最大长度检测
        if (!verify()) {
            return false;
        }
        var postData = {
            strEntity: JSON.stringify($('#form').lrGetFormData())
        };
        $.lrSaveForm(top.$.rootUrl + '/ZZDT_EC/ec_project_bakup/SaveForm?keyValue=' + keyValue, postData, function (res) {
            // 保存成功后才回调
            if (!!callBack) {
                callBack();
            }
        });
    };
    page.init();
}
//文字特殊字符及最大长度检测
function verify() {
    var msg = checkStr($("#BakupName").val(), 200);
    if (msg) {
        $.lrValidformMessage($("#BakupName"), msg);
        $('#BakupName').click();
        return false;
    }
    msg = checkStr($("#Remark").val(), 500);
    if (msg) {
        $.lrValidformMessage($("#Remark"), msg);
        $('#Remark').click();
        return false;
    }
    return true;
}